Skip to content

Conversation

@roomote
Copy link

@roomote roomote bot commented Nov 6, 2025

This PR addresses Issue #8270 based on @bozoweed's suggestion.

Problem

When using DeepSeek V3.1 Terminus via OpenRouter, reasoning/thinking appears to be enabled by default with no way to turn it off. This leads to worse answers for some tasks and increases token usage.

Solution

Following @bozoweed's insight, this PR implements the chat_template_kwargs approach with the thinking parameter for DeepSeek V3.1 Terminus models:

  • Add support for chat_template_kwargs in the OpenRouter handler
  • For DeepSeek V3.1 Terminus models, convert reasoning configuration to chat_template_kwargs: { thinking: boolean }
  • Remove the reasoning parameter for these models (replaced by chat_template_kwargs)
  • Default to thinking: false when no reasoning is configured

Changes

  • src/api/providers/openrouter.ts: Add DeepSeek V3.1 Terminus special handling for both streaming and non-streaming requests
  • src/api/providers/tests/openrouter.spec.ts: Add comprehensive tests for the new behavior

Testing

  • Added unit tests to verify:
    • thinking: true when reasoning is enabled
    • thinking: false when reasoning is disabled (default)
    • No chat_template_kwargs for non-Terminus models
    • Both streaming and non-streaming paths work correctly
  • All existing tests continue to pass

Fixes #8270

Thanks to @bozoweed for the solution!


Important

Introduces chat_template_kwargs for DeepSeek V3.1 Terminus models to control reasoning, replacing the reasoning parameter.

  • Behavior:
    • Implements chat_template_kwargs with thinking parameter for DeepSeek V3.1 Terminus models in openrouter.ts.
    • Removes reasoning parameter for these models, defaults thinking: false if not configured.
  • Testing:
    • Adds tests in openrouter.spec.ts to verify thinking: true when reasoning is enabled, thinking: false when disabled.
    • Ensures no chat_template_kwargs for non-Terminus models.
    • Tests both streaming and non-streaming paths.
  • Misc:

This description was created by Ellipsis for 52be5e5. You can customize this summary. It will automatically update as commits are pushed.

…ntrol

- Add chat_template_kwargs support to OpenRouterChatCompletionParams type
- Convert reasoning configuration to chat_template_kwargs for DeepSeek V3.1 Terminus models
- Set thinking parameter based on reasoning enabled state (not excluded)
- Add comprehensive tests for the new behavior
- Ensures reasoning can be properly disabled (default OFF) for DeepSeek V3.1 Terminus

Fixes #8270
@roomote roomote bot requested review from cte, jr and mrubens as code owners November 6, 2025 18:59
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Nov 6, 2025
@roomote
Copy link
Author

roomote bot commented Nov 6, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete - no issues found. The implementation correctly converts DeepSeek V3.1 Terminus reasoning configuration to chat_template_kwargs as suggested by @bozoweed.

Mention @roomote in a comment to trigger your PR Fixer agent and make changes to this pull request.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 6, 2025

const transforms = (this.options.openRouterUseMiddleOutTransform ?? true) ? ["middle-out"] : undefined

// Special handling for DeepSeek V3.1 Terminus models
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the DeepSeek-specific logic (converting reasoning to chat_template_kwargs) into a helper function to reduce duplication (appears in both createMessage and completePrompt).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] OpenRouter DeepSeek V3.1 Terminus forces reasoning; cannot disable

3 participants